package com.dx.architectureddd.app.chain.third;

import com.dx.architectureddd.common.dp.pipeline.ContextHandler;
import com.dx.architectureddd.common.dp.policy.HandlerFactory;
import com.dx.architectureddd.domain.service.ThirdService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * 第三方能力执行
 *
 * @author xin.deng
 * @date 2023/09/24
 */
@Component
public class ThirdInit implements ContextHandler<ThirdContext> {

    @Resource
    private HandlerFactory<String, ThirdService> submitProcessHandlerFactory;

    @Override
    public boolean handle(ThirdContext context) {
        String strategyType = context.getStrategyType();
        if (strategyType == null || "".equals(strategyType)) {
            return false;
        }
        submitProcessHandlerFactory.getStrategy(strategyType).process(context);
        return true;
    }
}
